#ifndef BASEMODULEWITHPORT_H
#define BASEMODULEWITHPORT_H

#include "basemodule.h"
#include "baseport.h"
#include "baseprotocol.h"

class BaseModuleWithPort : public BaseModule
{
    Q_OBJECT

public:
    BaseModuleWithPort(QObject *parent = nullptr);
    virtual ~BaseModuleWithPort();

    void setPort(BasePort *port);
    BasePort *getPort(void);
    void setProtocol(BaseProtocol *protocol);
    BaseProtocol *getProtocol(void);

signals:
    void requestSend(const QByteArray &ba);
    void parseCompleted(int id, const QVariant &data);

public slots:
    void onParse(QList<ProtocolPacket> packets);
    virtual void onParseCompleted(int id, const QVariant &data);

protected:
    BasePort                                *m_port = nullptr; // 该变量不常使用，因为通过信号槽连接了
    BaseProtocol                            *m_protocol = nullptr;
};

#endif // BASEMODULEWITHPORT_H
